const { request} = require('./request.js')

module.exports={

  //搜索接口
  goodsSearch:(k)=>request('shop/goods/list','POST',{k},true),
  //轮播图
  getBanner: () => request('banner/list','GET',{type:'index'},true),
  //分类接口
  getGoodsCate: () => request('shop/goods/category/all','GET','',true),
  //商品列表
  getGoodsList: () => request('shop/goods/list','POST',{},true),
  //商品推荐 0:代表一般商品 1:代表推荐商品
  getGoodsRecommend: () => request('shop/goods/list', 'POST', { recommendStatus:1},true),
  //获取拼团商品
  getGoodsPingtuan: () => request('shop/goods/list', 'POST', { pingtuan: true }, true),
  //根据商品分类，切换指定分类下的商品列表
  getCateList: (categoryId) => request('shop/goods/list','POST', { categoryId},true),
  //商品详情接口
  getGoodsDetail: (id) => request('shop/goods/detail','GET',{id},true),
  //添加商品收藏
  addFavGoods: (goodsId, token) => request('shop/goods/fav/add', 'POST', { goodsId,token},true),
  //删除商品收藏  
  removeFavGoods: (goodsId, token) => request('shop/goods/fav/delete','POST', { goodsId,token},true),
  //查看收藏列表
  getFavGoodsList: () => request('shop/goods/fav/list','POST',{},true),
  
  /**
   * 封装用户注册接口
   * data中要传递的参数说明：对象形式接收
   * code:wx.login登录凭证
   * iv:加密算法的初始向量
   * encryptedData：包括敏感数据在内的完整用户信息的加密数据
   */

  userRegister: (data) => request('user/wxapp/register/complex', 'POST', data,true),
  /**
   * 登录接口
   * 参数：code：通过wx.login获取传入的
   */

  userLogin: (code) => request('user/wxapp/login','POST',{code},true),
  /**
   * 检测token是否失效
   * 
   */
  checkToken: token => request('user/check-token','GET',{token},true),
  //读取用户详情
  getUserDetail: token => request('user/detail','GET',{token},true),
  //读取个人资产接口
  getUserBalanceDetail: token => request('user/amount','GET',{token},true),
  /**
   * 订单统计接口
   * 参数说明如下：
   * count_id_no_pay: 待支付订单数量--待付款
   * count_id_no_transfer: 已支付等待商家发货订单数量--待发货
   * count_id_no_confirm: 商家已发货，等待确认收货订单数量--待收货
   * count_id_no_reputation: 交易成功，等待评价的订单数量--待评价
   */
  getOrdersStatus: token => request('order/statistics','GET',{token},true)
}